/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * uiLayout.java
 *
 * Created on Mar 19, 2011, 12:25:49 AM
 */

package org.doscom.app.teawelcome.ui;

import javax.swing.JOptionPane;
import org.doscom.app.teawelcome.appbuilder.runtime;

/**
 *
 * @author home
 */
public class uiLayout extends javax.swing.JFrame {

    int level=1;
    runtime r=new runtime();
    /** Creates new form uiLayout */
    public uiLayout() {
        super("Welcome to Tealinux OS 3.0");
        initComponents();
        //setIconImage(getClass().getResource(null));
        //level=0;
        setGlassPane(new welcomePanel());
        getGlassPane().setVisible(false);
        getGlassPane().setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelImage1 = new org.doscom.app.teawelcome.template.panelImage();
        buttonNext = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setUndecorated(true);

        buttonNext.setFont(new java.awt.Font("Ubuntu", 1, 24));
        buttonNext.setText("Next >");
        buttonNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonNextActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelImage1Layout = new javax.swing.GroupLayout(panelImage1);
        panelImage1.setLayout(panelImage1Layout);
        panelImage1Layout.setHorizontalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage1Layout.createSequentialGroup()
                .addContainerGap(652, Short.MAX_VALUE)
                .addComponent(buttonNext, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panelImage1Layout.setVerticalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage1Layout.createSequentialGroup()
                .addContainerGap(535, Short.MAX_VALUE)
                .addComponent(buttonNext)
                .addGap(30, 30, 30))
        );

        getContentPane().add(panelImage1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonNextActionPerformed
        // TODO add your handling code here:
        //level=1;
        if(level>=3){
            buttonNext.setText("Finish");
            setGlassPane(new developer());
            getGlassPane().setVisible(false);
            getGlassPane().setVisible(true);
            if(level==4){
                this.dispose();
                int respon=JOptionPane.showConfirmDialog(null, "save setting and reboot now?", "confirmation reboot", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                if(respon==0){
                    r.reboot();
                }
                //setGlassPane(new developer());
            }else{
                level++;
            }
        }else{
            level++;
            if(level==2){
                //title.setText("init");
                setGlassPane(new localhostSetting());
                getGlassPane().setVisible(false);
                getGlassPane().setVisible(true);
            }else if(level==3){
                setGlassPane(new grubSetting());
                getGlassPane().setVisible(false);
                getGlassPane().setVisible(true);
            }
        }
        
    }//GEN-LAST:event_buttonNextActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new uiLayout().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonNext;
    private org.doscom.app.teawelcome.template.panelImage panelImage1;
    // End of variables declaration//GEN-END:variables

}
